import axios from 'axios'
import { Message } from 'element-ui'

// 创建axios实例
const service = axios.create({
  baseURL: 'http://localhost:8080',
  timeout: 15000 // 请求超时时间
})

// http request 拦截器
service.interceptors.request.use(
  config => {
    // debugger
    config.headers.Authorization = 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxODcxMDAyMzA2OCIsImV4cCI6MTU5MDI5NzUyOX0.V4bws7nVo8OBKMkps94YniafTnYZhNsDVHViCg-fKuRhYZLYvARQUt0SOjggi8e4_qqKB3Ys1udd79cRpq2AYA'
    return config
  },
  err => {
    return Promise.reject(err)
  })
// http response 拦截器
service.interceptors.response.use(
  response => {
    console.log(response)
    // 登录处理 debugger
    return response.data
  },
  error => {
    return Promise.reject(error.response)
  })
export default service
